package com.bawei.mall.search.service.impl;

import com.bawei.mall.search.domain.HotWord;
import com.bawei.mall.search.mapper.KeyWordSearchMapper;
import com.bawei.mall.search.service.KeyWordSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author：sxq
 * @Package：com.bawei.mall.search.service.impl
 * @Project：mall_cloud
 * @name：KeyWordSearchServiceImpl
 * @Date：2024/6/25 20:21
 */
@Service
public class KeyWordSearchServiceImpl implements KeyWordSearchService {

    @Autowired
    private KeyWordSearchMapper keyWordSearchMapper;

    @Override
    public List<String> byKeyWords() {
        List<String> strings = keyWordSearchMapper.byKeyWords();
        return strings;

    }

    @Override
    @Transactional
    public void addKeyWords(HotWord keyWords) {
        if(keyWords != null){
            keyWordSearchMapper.addKeyWords(keyWords);
            keyWordSearchMapper.updKeyWords(keyWords.getHotword());
        }
    }
}
